/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package unb.wikinarua.geopartitura.view;

import java.util.List;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Join;
import android.view.View;

public class MenuLineView extends View {

	private List<MenuButtonView> options;
	private Paint paint = new Paint();
	
	public MenuLineView(Context context, List<MenuButtonView> options) {
		super(context);
		
		this.options = options;
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);

		float centerX = canvas.getWidth() / 2;
		float centerY = canvas.getHeight() / 2;
		
		// 
		paint.setStrokeWidth(5f);
		paint.setStrokeCap(Cap.ROUND);
		paint.setStrokeJoin(Join.ROUND);
		paint.setAntiAlias(true);

		// Draw Center Circle
		paint.setColor(Color.BLACK);
		canvas.drawCircle(centerX, centerY, 15f, paint);
		
		// Draw Other Circles
		canvas.drawLine(centerX, centerY, centerX - 90, centerY - 10, paint);
		canvas.drawCircle(centerX - 90, centerY - 10, 15f, paint);
		paint.setColor(Color.YELLOW);
		canvas.drawCircle(centerX - 90, centerY - 10, 10f, paint);
		paint.setColor(Color.BLACK);
		
		canvas.drawLine(centerX, centerY, centerX + 90, centerY - 100, paint);
		canvas.drawCircle(centerX + 90, centerY - 100, 15f, paint);
		paint.setColor(Color.RED);
		canvas.drawCircle(centerX + 90, centerY - 100, 10f, paint);
		paint.setColor(Color.BLACK);
		
		canvas.drawLine(centerX, centerY, centerX + 70, centerY + 100, paint);
		canvas.drawCircle(centerX + 70, centerY + 100, 15f, paint);
		paint.setColor(Color.GREEN);
		canvas.drawCircle(centerX + 70, centerY + 100, 10f, paint);
		paint.setColor(Color.BLACK);
		
		// Draw Lines to Buttons
		for (int i = 0; i < options.size(); i++) {
			canvas.drawLine(centerX, centerY, centerX + options.get(i).getX(), 
					centerY + options.get(i).getY(), paint);
		}
	}
	
}
